﻿using FullApp1.Modules.ModuleName.Models;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;

public class OperatorDetailDialogModel : BindableBase, IDialogAware
{
    private LegalPerson _operator;

    // 实现 IDialogAware 必须的 RequestClose 事件
    public event Action<IDialogResult> RequestClose;
    public string Title => "经营者详情";

    public LegalPerson Operator
    {
        get => _operator;
        set => SetProperty(ref _operator, value);
    }
    

    public bool CanCloseDialog() => true;

    public void OnDialogOpened(IDialogParameters parameters)
    {
        // ✅ 安全获取参数
        if (parameters.TryGetValue<LegalPerson>("operator", out var operatorObj))
        {
            Operator = operatorObj;
        }
    }

    public void OnDialogClosed()
    {
        // 清理非托管资源（可选）
    }

    // 添加关闭对话框的逻辑（示例）
    private void CloseDialog()
    {
        RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
    }
}